<?php
	session_start();
	require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../../model/Service/ArticleService.php';
    require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../../model/Context/BaseContext.php';
    require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../../model/ServiceResult/ServiceResult.php';
    $articleService = new ArticleService();
    $context = new BaseContext();
	$result = new ServiceResult();
	if(isset($_GET['type']))
	{
		$type = $_GET['type'];
		
		if($type == "articleCode")
		{
			if(isset($_POST['code']))
			{	
				$code = $_POST['code'];
				$rs = $articleService->checkCodeExist($context, $result, $code);
				if($rs == true)
					echo "<span style='color: red;'>( Code is exist, please input another code!!!! )</span>";
				else
					echo "<span style='color: green;'>( Available )</span>";
			}
		}
	}
?>